package com.piper.rabbit.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * https://blog.csdn.net/lyhkmm/article/details/78772919
 * https://www.rabbitmq.com/getstarted.html
 */
@Configuration
public class RabbitConfig {

    @Bean
    public Queue hello() {
        return new Queue("hello");
    }


    @Bean
    public Queue work_queue() {
        return new Queue("work_queue");
    }


    /**
     * 主题模式
     */
    @Bean
    public Queue topic_queue() {
        return new Queue("topic_queue");
    }
    @Bean
    public Queue topic_queue1() {
        return new Queue("topic_queue1");
    }
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("topicExchange");
    }
    @Bean
    public Binding bindingExchangeMessage(Queue topic_queue, TopicExchange topicExchange) {
        return BindingBuilder.bind(topic_queue).to(topicExchange).with("topic.#");
    }
    @Bean
    public Binding bindingExchangeMessage1(Queue topic_queue1, TopicExchange topicExchange) {
        return BindingBuilder.bind(topic_queue1).to(topicExchange).with("topic.a");
    }

}
